<template>
  <div class="header-wrapper">
    <div class="header-content">
      <div class="nav-logo">
        <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
      </div>
      <div class="nav-text">
        <ul>
          <router-link to="/index" tag="li">首页</router-link>
          <router-link to="/goods" tag="li">全部礼品</router-link>
          <router-link @click.native="toUser" to="/user" tag="li"
            >个人中心</router-link
          >

          <router-link to="/dingdan" tag="li">我的订单</router-link>
          <router-link to="/fuli" tag="li">专属福利</router-link>
        </ul>
      </div>
      <div class="nav-serch">
        <input type="text" placeholder="输入关键字" />
        <div class="nav-btn"></div>
      </div>
    </div>
  </div>
</template>

<script>
import bus from "../bus";

export default {
  data() {
    return {};
  },
  methods: {
    toUser() {
      if (!localStorage.getItem("token")) {
        bus.$emit("loginshow", true);
        this.$toast({
          message: "请先登录",
          type: "fail",
          duration: 2000, // 显示的时长
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.active {
  font-weight: bold;
  color: #0a328e;
}
.header-wrapper {
  height: 72px;
  padding-top: 12px;
  .header-content {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    width: 1200px;
    margin: 0 auto;
    .nav-text {
      ul {
        display: flex;
        li {
          cursor: pointer;
          margin-right: 53px;
          &.router-link-exact-active {
            font-weight: bold;
            color: #0a328e;
          }
        }
      }
    }
    .nav-serch {
      display: flex;
      width: 264px;
      height: 38px;
      input {
        height: 34px;
        width: 190px;
        padding-left: 20px;
        outline: none;
        border-top-left-radius: 17px;
        border-bottom-left-radius: 17px;
        border: solid 1px #dedede;
      }
      .nav-btn {
        width: 50px;
        height: 38px;
        border-top-right-radius: 17px;
        border-bottom-right-radius: 17px;
        background-color: #0a328e;
        background-image: url(../assets/img/search.png);
        background-repeat: no-repeat;
        background-size: 20px;
        background-position: 12px 9px;
      }
    }
  }
}
</style>
